package com.newly.common.base.entity.auth;

import cn.hutool.core.util.StrUtil;

import java.util.List;

/**
 * @program: newly-parent
 * @remark: 当前租户基了类
 * @author: guan
 * @create: 2022-01-02 22:03
 */
public class AbstractCurrentTenant {
    /**
     * 用户信息，包括权限信息
     */
    protected TenantDetails tenantDetails;
    /**
     * 默认错误消息
     */
    protected static final String DEFAULT_ERR_MSG = "No has permissions!";
    /**
     * 包含
     */
    protected static final int INCLUDE = 1;
    /**
     * 不包含
     */
    protected static final int EXCLUDE = 0;

    public Long getUserId() {
        return tenantDetails.getUserId();
    }

    public String getNickname() {
        return tenantDetails.getNickname();
    }

    public String getUsername() {
        return tenantDetails.getUsername();
    }

    public int getType() {
        return tenantDetails.getType();
    }

    public List<AuthPayload> getAuthPayloads() {
        return tenantDetails.getAuthPayloads();
    }

    /**
     * @param errMsg 源错误消息
     * @return 返回错误消息
     */
    protected String getErrMsg(String errMsg) {
        return StrUtil.isBlank(errMsg) ? DEFAULT_ERR_MSG : errMsg;
    }
}
